"""
主题: 创建大量对象时节省内存方法
问题: 你的程序要创建大量(可能上百万)的对象，导致占用很大的内存。
提示 : 
"""

import sys


class SlotDate:
    __slots__ = ['year', 'month', 'day']

    def __init__(self, year, month, day):
        self.year = year
        self.month = month
        self.day = day

class Date:
     def __init__(self, year, month, day):
        self.year = year
        self.month = month
        self.day = day

def recipe1():
    print(f"{sys.getsizeof(Date(1, 1, 1)) = }")
    print(f"{sys.getsizeof(SlotDate(1, 1, 1)) = }")

def main():
    print('recipe1'.center(20, '*'))
    recipe1()

if __name__ == '__main__':
    main()     